#include "ResultTable.h"


ResultGridTable::ResultGridTable()
{

}

ResultGridTable::~ResultGridTable()
{
	if( !result.IsEmpty() )
		result.Clear();
	nullArray.Clear();
	/*if ( this ){
		delete this;
	}*/
}

void ResultGridTable::SetValue(int row, int col, const wxString &value)
{
	
}

void ResultGridTable::Bind(int row, int col, wxArrayString& result,NullArray nullArray)
{
	this->row = row;
	this->col = col;
	this->result = result;
	this->nullArray = nullArray;
	this->nullPos = 0;
}

wxString ResultGridTable::GetValue( int row, int col ){
	if ( row % 2 != 0 ){
		wxGridCellAttr *attr;
		attr = new wxGridCellAttr;
		attr->SetBackgroundColour(wxColor(238,238,238));
		SetRowAttr(attr,row);
	}
	if ( nullArray.GetCount() ==0 )
		return result[(row+1)*this->col+col];
	if ( (row+1)*this->col+col == nullArray[nullPos] ){
	    wxGridCellAttr *attr = GetAttr(row, col, wxGridCellAttr::Any);
		if ( attr == NULL ){
			attr = new wxGridCellAttr;
		}
		attr->SetBackgroundColour(wxColor(255,255,225));
		SetAttr(attr,row,col);
		++nullPos;
	}
	return result[(row+1)*this->col+col];
}

int ResultGridTable::GetNumberRows() {
    
	/*if ( row % 2 == 0 ){
		wxGridCellAttr *attr = new wxGridCellAttr;
		attr->SetBackgroundColour(*wxLIGHT_GREY);
		SetRowAttr(attr,row);
	}*/
/*    if ( row % 2 )
    {
        if ( !attr )
        {
            attr = m_attrForOddRows;
            attr->IncRef();
        }
        else
        {
            if ( !attr->HasBackgroundColour() )
            {
                wxGridCellAttr *attrNew = attr->Clone();
                attr->DecRef();
                attr = attrNew;
                attr->SetBackgroundColour(*wxLIGHT_GREY);
            }
        }
    }*/

	return row; 
}
